package com.ostrich.library_common.views;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

import androidx.annotation.Nullable;

/**
 * 自定义TextView，字体样式
 * @Author : yaotianxue
 * @Time : On 2023/10/24 15:11
 * @Description : CommonCustomTextView
 */
@SuppressLint("AppCompatCustomView")
public class CommonCustomTextView extends TextView {
    public CommonCustomTextView(Context context) {
        super(context);
        init(context);
    }

    public CommonCustomTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public CommonCustomTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public CommonCustomTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }


    private void init(Context context){
        //获得assets目录下字体样式
        AssetManager assets = context.getAssets();
        Typeface font = Typeface.createFromAsset(assets, "fonts/Lobster-1.4.otf");
        setTypeface(font);
    }
}
